package com.iot08.api.controller;

import com.iot08.api.service.ComplaintReasonService;
import com.iot08.api.service.ComplaintService;
import com.iot08.api.vo.request.ComplaintReportReqVO;
import com.iot08.api.vo.request.IdParamReqVO;
import com.iot08.api.vo.request.UserExitsReqVo;
import com.iot08.common.utils.response.ResponseMap;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @version 1.0
 * @Description: 投诉
 * @time: 2021/5/7 11:42
 * @author: Rock
 */
@RestController
@RequestMapping("getway/complaint")
public class ComplaintController {

    @Resource
    private ComplaintReasonService complainReasonService;
    @Resource
    private ComplaintService complaintService;

    /**
     * 投诉原因列表
     *
     * @time: 2021/5/7 11:46
     * @author: Rock
     * @version 1.0
     */
    @GetMapping("listReason")
    public ResponseMap listReason() {
        return complainReasonService.listData();
    }

    /**
     * 投诉上报
     *
     * @param vo
     * @param bindingResult
     * @param image1
     * @param image2
     * @param image3
     * @time: 2021/5/7 17:36
     * @author: Rock
     * @version 1.0
     */
    @PostMapping("report")
    public ResponseMap report(@Validated ComplaintReportReqVO vo, BindingResult bindingResult,
                              @RequestParam(name = "image1", required = false) MultipartFile image1,
                              @RequestParam(name = "image2", required = false) MultipartFile image2,
                              @RequestParam(name = "image3", required = false) MultipartFile image3
    ) throws IOException {
        return complaintService.report(vo, image1, image2, image3);
    }


    @PostMapping({"/addComplainReason"})
    public ResponseMap addCom(@RequestParam("content") String content) {
        return complainReasonService.addData(content);
    }

}
